package com.example.jinyongjie.test_opengles.programs;

import android.content.Context;

import com.example.jinyongjie.test_opengles.util.ShaderHelper;
import com.example.jinyongjie.test_opengles.util.TextResourceReader;
import static android.opengl.GLES20.*;
/**
 * Created by jinyongjie on 17/3/23.
 */
public class ShaderProgram {
    protected static final  String U_COLOR = "u_Color";
    protected  static final String A_POSITION = "a_Position";
    protected static final String U_MATRIX = "u_Matrix";
    protected static final String U_TEXTURE = "u_TextureUnit";
    protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";

    protected int m_program;
    public ShaderProgram(Context context,int vertexShaderResourceId,
                         int fragmentShaderResourceId)
    {
        String vertexShaderSource = TextResourceReader.readTextFileFromResource(context, vertexShaderResourceId);
        String fragShaderSource = TextResourceReader.readTextFileFromResource(context, fragmentShaderResourceId);
        m_program = ShaderHelper.buildProgram(vertexShaderSource,fragShaderSource);
    }
    public void useProgram()
    {
        glUseProgram(m_program);
    }
}
